﻿using System;
using System.Collections.Generic;
using System.Text;
using AdaptiveAgents.Loggers;

namespace AdaptiveAgents.Agents
{
    /// <summary>
    /// Director that uses agenet builders - 'Builder' design pattern
    /// </summary>
    public class AgentDirector
    {
        private AgentBuilder _builder; //builder instance

        /// <summary>
        /// Sets a builder that the director can use
        /// </summary>
        public AgentBuilder Builder
        {
            set { _builder = value; }
        }

        /// <summary>
        /// Gets new created agent from builder
        /// </summary>
        /// <returns>New created agent</returns>
        public Agent getAgent()
        {
            return _builder.getAgent();
        }

        /// <summary>
        /// Creates an instance of agent according to given parameters
        /// </summary>
        /// <param name="id">Agent ID</param>
        /// <param name="env">EnvironmentType of the agent</param>
        /// <param name="eps">Exploration factor of the agent</param>
        /// <param name="logger">Logger that keeps tracking of agent data</param>
        public void construct(int id, Environment env, double eps, Logger logger)
        {
            _builder.create(id, env, eps, logger);
            _builder.buildMemoryOfAgent();
            _builder.buildNextPlayerDecision();
            _builder.buildNextPlayerPrediction();
        }
    }

}
